Ext.define('CA.catalog.Module', {
    extend: 'Ext.ux.desktop.Module',

    uses: [
        'CA.base.PriceChanger',

        'CA.catalog.FilterTree',
        'CA.catalog.ObjectsTable'
    ],

    id: 'module-catalog',

    moduleInfo: {
        name: 'Каталог недвижимости',
        iconCls: 'c-icon-catalog'
    },

    init : function(){
        this.launcher = {
            text: this.moduleInfo.name,
            iconCls: this.moduleInfo.iconCls,
            handler : this.createWindow,
            scope: this
        };
    },

    createWindow: function(){
        var desktop = this.app.getDesktop(),
            win = desktop.getWindow(this.id);

        if(!win){
            win = desktop.createWindow({
                id: this.id,
                title: this.moduleInfo.name,
                iconCls: this.moduleInfo.iconCls,
                width: '90%',
                height: '90%',
                border: false,
                layout: 'border',
                items: [
                    {
                        region: 'center',
                        xtype: 'CA.catalog.ObjectsTable'
                    },
                    {
                        width: 250,
                        minWidth: 250,
                        region: 'east',
                        split: true,
                        xtype:'CA.catalog.FilterTree',
                        title: 'Фильтрация',
                        dockedItems: [
                            {
                                xtype: 'CA.base.PriceChanger',
                                weight: 2,
                                dock: 'bottom',
                                minValue: 0,
                                maxValue: 100000,
                                money: '€'
                            }
                        ]
                    }
                ]
            });
        }

        win.show();

        return win;
    }
});